<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {include file="/layout/scriptload"}
    <title>编辑账号池</title>
</head>
<body>
<div class="box">
    <!-- /.box-header -->
    <section class="content">
        <div class="box-body">
            <form role="form">
                <div class="form-group col-md-7">
                    <label>账号池名</label>
                    <input type="text" id="poolname" class="form-control"  value="{$data.poolname}">
                </div>
                <div class="form-group col-md-7">
                    <label>说明</label>
                    <textarea class="form-control" id="remark" cols="30" rows="3">{$data.remark}</textarea>
                </div>
                <div class="form-group col-md-7">
                    <label>总分类名称</label>
                    <select id="category_sum" class="form-control">
                        <option value="0" selected="selected">请选择...</option>
                        {volist name="category_sum" id="v"}
                        <option value="{$v.id}" {if condition="$v['id'] eq $data['category_sum']"}selected="selected"{/if}>{$v.categoryname}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group col-md-7">
                    <label>子分类名称</label>
                    <select id="category_child" class="form-control">
                        <option value="">请选择...</option>
                        {volist name="category_child" id="vo"}
                        <option value="{$vo.id}" {if condition="$vo['id'] eq $data['category_child']"}selected="selected"{/if}>{$vo.categoryname}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group col-md-7">
                    <label>屏蔽规则</label>
                    <select id="shieldrule" class="form-control">
                        <option value="">请选择...</option>
                        {volist name="shieldrule" id="vol"}
                        <option value="{$vol.id}" {if condition="$vol['id'] eq $data['shieldrule']"}selected="selected"{/if} >{$vol.rulename}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group col-md-7">
                    <label>返回循环组</label>
                    <select id="rotarygroups" class="form-control">
                        <option value="">请选择...</option>
                    </select>
                </div>
                <div class="form-group col-md-7">
                    <label>使用外链</label>
                    <div class="radio">
                        <label>
                            <input type="radio" name="outerlink" {if condition="$data['outerlink'] eq 1"}checked="checked"{/if} value="1">使用
                        </label>
                        <label>
                            <input type="radio" name="outerlink" {if condition="$data['outerlink'] eq 2"}checked="checked"{/if} value="2">不使用
                        </label>
                    </div>
                </div>
                <div class="form-group col-md-7">
                    <label>权重开关</label>
                    <div class="radio">
                        <label>
                            <input type="radio" name="is_weight" {if condition="$data['is_weight'] eq 1"}checked="checked"{/if} value="1">使用
                        </label>
                        <label>
                            <input type="radio" name="is_weight" {if condition="$data['is_weight'] eq 2"}checked="checked"{/if} value="2">不使用
                        </label>
                    </div>
                </div>
                <div class="form-group col-md-7">
                    <label>图文条数</label>
                    <select id="imgtext_num" class="form-control">
                        <option {if condition="$data['imgtext_num'] eq 1"}selected="selected"{/if} value="1">1</option>
                        <option {if condition="$data['imgtext_num'] eq 2"}selected="selected"{/if} value="2">2</option>
                        <option {if condition="$data['imgtext_num'] eq 3"}selected="selected"{/if} value="3">3</option>
                        <option {if condition="$data['imgtext_num'] eq 4"}selected="selected"{/if} value="4">4</option>
                        <option {if condition="$data['imgtext_num'] eq 5"}selected="selected"{/if} value="5">5</option>
                        <option {if condition="$data['imgtext_num'] eq 6"}selected="selected"{/if} value="6">6</option>
                        <option {if condition="$data['imgtext_num'] eq 7"}selected="selected"{/if} value="7">7</option>
                        <option {if condition="$data['imgtext_num'] eq 8"}selected="selected"{/if} value="8">8</option>
                    </select>
                </div>
                <input type="hidden" id="cid" value="{$data.id}">
                <div class="form-group col-md-7" >
                    <div id="btn_save" class="btn pull-right" style="background: #18bc9c;color: #ffffff;">保存</div>
                </div>
            </form>
        </div>
    </section>
</div>
</body>
<script>
    $(function(){
        $("#category_sum").change(function () {
            var _id = $(this).val();
            $.ajax({
                type: 'post',
                cache: false,
                url: '{:url("admin/Replyfans/getCategoryChild")}',
                data: {cid: _id},
                success: function (data) {
                    if (data.code == "0") {
                        $("#category_child option").remove();
                        var html = '<option value="">请选择...</option>';
                        $("#category_child").append(html);
                        $.each(data.info, function (index, item) {
                            var html = '<option value="' + item.id + '">' + item.categoryname + '</option>';
                            $("#category_child").append(html);
                        });
                    }
                }
            });
        });
        $('#btn_save').click(function(){
            var _cid = $('#cid').val();
            var _poolname = $('#poolname').val();
            var _remark = $('#remark').val();
            var _category_sum = $('#category_sum').val();
            var _category_child = $('#category_child').val();
            var _shieldrule = $('#shieldrule').val();
            var _rotarygroups = $('#rotarygroups').val();
            var _imgtext_num = $('#imgtext_num').val();
            var _outerlink = $("input[name='outerlink']:checked").val();
            var _is_weight = $("input[name='is_weight']:checked").val();
            if(_poolname == ''){
                layerAlert('账号池不能为空');
                return false;
            }
            if(_category_sum == ''){
                layerAlert('请选择总分类');
                return false;
            }
            if(_category_child == ''){
                layerAlert('请选择子分类');
                return false;
            }
            if(_shieldrule == ''){
                layerAlert('请选择屏蔽规则');
                return false;
            }
            $.ajax({
                type:'post',
                cache: false,
                url:"{:url('replyfans/doEditPool')}",
                data:{id:_cid,poolname:_poolname,remark:_remark,is_weight:_is_weight,outerlink:_outerlink,imgtext_num:_imgtext_num,category_sum:_category_sum,category_child:_category_child,shieldrule:_shieldrule,rotarygroups:_rotarygroups},
                success:function(data){
                    if(data.code==0){
                        layerAlert(data.msg,function(){
                            parent.relist();
                            layerParentClose();
                        });
                    }else{
                        layerAlert(data.msg);
                    }
                }
            })
        })
    })
</script>
</html>